﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for CustomerDAL
/// </summary>
public class CustomerDAL
{
    DataAccess db = new DataAccess();
	public CustomerDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public int insertCustomer(Customer customer)
    {

        SqlParameter[] paramList = new SqlParameter[8];
        paramList[0] = new SqlParameter("@CustomerId", SqlDbType.VarChar,30);
        paramList[0].Value = customer.Username;
        paramList[1] = new SqlParameter("@UserName", SqlDbType.VarChar, 50);
        paramList[1].Value = customer.Username;
        paramList[2] = new SqlParameter("@Password", SqlDbType.VarChar, 20);
        paramList[2].Value = customer.Password;
        paramList[3] = new SqlParameter("@FullName", SqlDbType.NVarChar, 50);
        paramList[3].Value = customer.Fullname;
        paramList[4] = new SqlParameter("@DateOfBirth", SqlDbType.DateTime);
        paramList[4].Value = customer.Dateofbirth;
        paramList[5] = new SqlParameter("@Gender", SqlDbType.Bit);
        paramList[5].Value = customer.Gender;
        paramList[6] = new SqlParameter("@Address", SqlDbType.NVarChar, 200);
        paramList[6].Value = customer.Address;
        paramList[7] = new SqlParameter("@Phone", SqlDbType.VarChar, 20);
        paramList[7].Value = customer.Phone;
    

        return db.executeUpdate("insertCustomer", paramList);
    }
    //login
    public DataTable getCustomerByUsername(string _username, string _password)
    {
        SqlParameter[] paramList = new SqlParameter[2];

        paramList[0] = new SqlParameter("@UserName", SqlDbType.VarChar, 50);
        paramList[0].Value = _username;
        paramList[1] = new SqlParameter("@Password", SqlDbType.VarChar, 20);
        paramList[1].Value = _password;

        return db.executeSelect("GetCustomerByUsername", paramList);
    }
  

}